﻿using System;
using Fcl = System.IO;

namespace Lukianol.IO
{
    /// <summary>
    /// Set of static methods to work with file pathes
    /// </summary>
    public static class Path
    {
        public static string ResolveFilePath(string filePath, string appRoot)
        {
            if (filePath == null)
                throw new ArgumentNullException("filePath");

            var pathRoot = Fcl.Path.GetPathRoot(filePath);
            var isRelativeToAppRoot = ((string.IsNullOrEmpty(pathRoot)) || (@"\".Equals(pathRoot)));
            return isRelativeToAppRoot ? Fcl.Path.Combine(appRoot, filePath.TrimStart('\\')) : filePath;
        }
    }
}
